import { Request } from "@/plugins/request";
import type { CreateSessionDto, SessionEntity, MessageEntity } from "@/typings/api/chat";

const request = new Request();

/**
 * 创建会话
 * @param  data {CreateSessionDto}
 * @returns
 */
export const createSession = (data: CreateSessionDto) => {
  return request.post<SessionEntity>("chat/createSession", data);
};

/**
 * 根据当前人id查询所有会话
 * @param id
 * @returns
 */
export const getAllSessions = (id: string | number) => {
  return request.get<SessionEntity[]>(`chat/getSessions/${id}`);
};

/**
 * 根据会话id获取消息
 * @param id 会话id
 * @returns
 */
export const getMessage = (id: string | number) => {
  return request.get<MessageEntity[]>(`chat/getMessages/${id}`);
};
